<?php

include '../../configs/global.php';
$data = $_POST;
$type = $data['type'];
$difficulty = $data['difficulty'];
$stem = $data['stem'];
$resourcesinfo = $data['resourcesinfo'];
$points = $data['points'];
$sid = $data['sid'];

//定义一个返回数组
$ajax_res = array();


$sql = "insert into questions(cid,type,stem,difficulty,points) values('{$sid}','{$type}','{$stem}','{$difficulty}','{$points}')";
$sel="select questions.id from questions order by id DESC limit 1";
$r1 = $pdo->exec($sql);
$row=$pdo->getOne($sel);
$sql1="insert into resources(qid,resourcesinfo) values('{$row['id']}','{$resourcesinfo}')";
$r2 = $pdo->exec($sql1);
if ($r1||$r2) {
    header('location:/study/style/skip.php?url=admin/showcurriculum.php&info=添加成功！');
} else {
    header('location:/study/style/skip.php?url=admin/showcurriculum.php&info=添加失败,请稍后再试!');
}

// echo json_encode($ajax_res);
